package com.element.security.model.entity;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther WuJun.Zhang
 * @date 2022/2/18 下午9:43
 */
@Data
public class AuthUserE implements UserDetails, Serializable {

    private static final long serialVersionUID = 1L;
    // 用户ID
    private String userId;

    // 用户密码
    private String password;

    // 拓展字段
    private Map<String, Object> expMap = new HashMap<>();

    // 权限
    private List<GrantedAuthority> authorities = new ArrayList<>();

    // 用户名称
    @Override
    public String getUsername() {
        return this.userId;
    }

    // 账号是否过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    // 账号是否锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    // 凭证是否未过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    // 是否有效
    @Override
    public boolean isEnabled() {
        return true;
    }
}